home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / svcitocx / service.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-08-29  |  3.6 KB  |  121 lines

  1. VERSION 5.00
  2. Object = "{5DA62B65-0D48-11D2-A6E3-00400541EFEE}#1.0#0"; "SvcIt.ocx"
  3. Begin VB.Form Main 
  4.    Caption         =   "Service-It Sample Beep Service"
  5.    ClientHeight    =   1380
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   4230
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   1380
  13.    ScaleWidth      =   4230
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin VB.CommandButton CmdAdmin 
  16.       Caption         =   "&Admin..."
  17.       Height          =   345
  18.       Left            =   2910
  19.       TabIndex        =   4
  20.       Top             =   780
  21.       Width           =   1155
  22.    End
  23.    Begin VB.Timer Timer1 
  24.       Interval        =   1000
  25.       Left            =   780
  26.       Top             =   720
  27.    End
  28.    Begin VB.TextBox State 
  29.       Height          =   315
  30.       Left            =   1320
  31.       TabIndex        =   3
  32.       Top             =   120
  33.       Width           =   2745
  34.    End
  35.    Begin VB.CommandButton LogEventBtn 
  36.       Caption         =   "LogEvent"
  37.       Height          =   345
  38.       Left            =   1320
  39.       TabIndex        =   1
  40.       Top             =   780
  41.       Width           =   1245
  42.    End
  43.    Begin SVCITLib.SvcIt MyService 
  44.       Height          =   480
  45.       Left            =   210
  46.       TabIndex        =   0
  47.       ToolTipText     =   "Right-Click here to debug"
  48.       Top             =   690
  49.       Width           =   480
  50.       _Version        =   65536
  51.       _ExtentX        =   847
  52.       _ExtentY        =   847
  53.       _StockProps     =   0
  54.       ServiceName     =   "BeepService"
  55.       DisplayName     =   ""
  56.       Dependencies    =   ""
  57.       MachineName     =   ""
  58.       ServiceExe      =   ""
  59.       PauseContinue   =   -1  'True
  60.       Priority        =   1
  61.    End
  62.    Begin VB.Label Label1 
  63.       Caption         =   "Service state:"
  64.       Height          =   255
  65.       Left            =   150
  66.       TabIndex        =   2
  67.       Top             =   180
  68.       Width           =   1095
  69.    End
  70. Attribute VB_Name = "Main"
  71. Attribute VB_GlobalNameSpace = False
  72. Attribute VB_Creatable = False
  73. Attribute VB_PredeclaredId = True
  74. Attribute VB_Exposed = False
  75. Private Sub CmdAdmin_Click()
  76.   Admin.Show 1
  77. End Sub
  78. Private Sub Form_Load()
  79.   MyService.PauseContinue = True
  80.   If (Not MyService.IsService) Then
  81.     ' Enable the admin button only if we have admin rights
  82.     CmdAdmin.Enabled = MyService.IsAdmin
  83.     ' Simulate a service start to avoid right-clicking on the control :-)
  84.     ' MyService.Start ""
  85.   Else
  86.     CmdAdmin.Enabled = False
  87.   End If
  88. End Sub
  89. Private Sub LogEventBtn_Click()
  90.   MyService.LogEvent "Error message!", 1
  91. End Sub
  92. Private Sub MyService_Continue()
  93.   State.Text = "Started"
  94. End Sub
  95. Private Sub MyService_Control(ByVal Code As Long)
  96.   State.Text = "Control(" + LTrim$(Str$(Code)) + ")"
  97. End Sub
  98. Private Sub MyService_Pause()
  99.   State.Text = "Paused"
  100. End Sub
  101. Private Sub MyService_Start(ByVal sParams As String)
  102.   State.Text = "Started Params=" + sParams
  103.   Rem If your initialization process fails, you
  104.   Rem can abort the service startup by calling the
  105.   Rem Abort(Error, SpecificError) method
  106.   Rem followed by the End Statement
  107.   Rem Example:
  108.   Rem MyService.Abort 0, 1
  109.   Rem End
  110.   MyService.LogEvent "The service was successfully started.", 4
  111. End Sub
  112. Private Sub MyService_Stop()
  113.   State.Text = "Stopped"
  114.   MyService.LogEvent "The service stop.", 4
  115. End Sub
  116. Private Sub Timer1_Timer()
  117.   If MyService.IsRunning() Then
  118.     Beep
  119.   End If
  120. End Sub
  121.